﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JYH.Data;
using Newtonsoft.Json;
using JYH.Model;
using JYH.DataAccess;
using JYH.Framework;
using System.Data;

namespace JYH.Business
{
    /// <summary>
    ///  BasStorageInfo
    /// </summary>
    public class BasStorageInfoBLL : BusinessBase<BasStorageInfo>
    {
        /// <summary>
        ///  BasStorageInfo
        /// </summary>
        public BasStorageInfoBLL()
        {
            myDataBase = DB.D();
            this.SqlSelect = @"; Select BasStorageInfo.*,
                                BasWarehouseInfo.WarehouseNO,
                                BasWarehouseInfo.WarehouseName
                                From BasStorageInfo
								Inner JOIn BasWarehouseInfo ON BasStorageInfo.WarehouseID=BasWarehouseInfo.WarehouseID";
        }

        /// <summary>
        /// 库位打印
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public DataSet GetStRInfos(string WarehouseID, string IDs, out string Msg)
        {
            string strSql = @";select BasStorageInfo.*   from BasStorageInfo";
            Sql sql = new Sql();
            sql.Append(strSql);
            if (!string.IsNullOrEmpty(IDs))
            {
                IDs = IDs.Substring(0, IDs.Length - 1);
                string sqls = string.Empty;
                string[] strs = IDs.Split(',');
                for (int i = 0; i < strs.Length; i++)
                {
                    sqls += "'" + strs[i].ToString() + "',";
                }
                sqls = sqls.Substring(0, sqls.Length - 1);
                sql.Append("WHERE BasStorageInfo.StorageID in (" + sqls + ")");
            }
            sql.Append("Where BasStorageInfo.WarehouseID='" + WarehouseID + "'");
            sql.OrderBy("BasStorageInfo.StorageNO");
            Msg = string.Empty;
            DataSet ds = new DataSet();
            myDataBase.Fill(ds, sql.SQL, null);
            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    ds.Tables[0].TableName = "BasStorageInfo";
                }
            }
            return ds;
        }
    }
}